package com.zdzh.socketio.socket.adapter;

import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
import org.springframework.stereotype.Component;

/**
 * @ author Shawn(Shawn_0108@163.com)
 * @ date & time 2023/10/13 14:45
 */
@RequiredArgsConstructor
@Component("fishListenerAdapter")
public class FishListenerAdapter extends MessageListenerAdapter {

    private final RedisTemplate redisTemplate;

    @Override
    public void onMessage(Message message, byte[] pattern) {
        JSONObject jsonObject = (JSONObject) redisTemplate.getValueSerializer().deserialize(message.getBody());
        System.out.println("我是Fish监听:" + jsonObject.toString());
    }
}
